package lynch.display 
{
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	/**
	 * a basic class of game window, if you update children in window, you have to use flatten() to update the display
	 * @see starling.display.Sprite#flatten();
	 * @author 小痛
	 */
	public class Window extends Container 
	{
		public static var BG_IMG_BIMAPDATA:BitmapData;
		public static var BG_IMG_9GRID:Rectangle;
		
		private var bgImg:Scale9Image;
		
		/**
		 * @throws	UninitializedError	you have to set Window.BG_IMG_BIMAPDATA first
		 * @param	width
		 * @param	height
		 */
		public function Window(width:int, height:int) 
		{
			super();
			
			if (BG_IMG_BIMAPDATA == null)
				throw new UninitializedError("you have to set Window.BG_IMG_BIMAPDATA first, otherwise, you can extends Container");
			
			bgImg = new Scale9Image(BG_IMG_BIMAPDATA, BG_IMG_9GRID, { width:width, height:height } );
			addChild(bgImg);
			flatten();
		}
		
	}

}